/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Beans;

import BLL.ExaminationBLL;
import Entities.TblExamination;
import Entities.TblSubject;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author CuongNV
 */
@ManagedBean
@RequestScoped
public class ExaminationManagedBean extends TblExamination{

    private TblExamination examSelected;
    
    /** Creates a new instance of ExaminationManagedBean */
    public ExaminationManagedBean() {
    }

    public String add() throws Exception {
        this.setEndDateToRequest(this.getExamDate());
        boolean check = new BLL.ExaminationBLL().add(this);
        if (check) {
            return "examlist";
        } else {
            return null;
        }
    }

    public String update() throws Exception {
        boolean check = new BLL.ExaminationBLL().update(examSelected);
        if (check) {
            return "examlist";
        } else {
            return null;
        }
    }

    public String delete() throws Exception{
        boolean check = new BLL.ExaminationBLL().delete(examSelected);
        if (check) {
            return "examlist";
        } else {
            return null;
        }
    }

    public TblExamination layExamById(int Id){
        return new BLL.ExaminationBLL().getById(Id);
    }

    public List<TblExamination> getAll() throws Exception {
        return new ExaminationBLL().getAll();
    }

    public TblExamination getBranchSelected() {
        return examSelected;
    }

    public void setBranchSelected(TblExamination examSelected) {
        this.examSelected = examSelected;
    }
    public TblSubject objSubjectById(int id){
        return new BLL.SubjectBLL().getById(id);
    }
}
